import QtQuick 2.9

Canvas{
    id:canvas
    x:320
    y:200
    width: 200
    height: 200
    smooth: true
    onPaint: {
        //获取画布上下文
        var ctx=getContext("2d")

        ctx.drawImage("images/ball.png",10,10)
        ctx.save()
        ctx.strokeStyle='red'
        ctx.beginPath()
        ctx.moveTo(100,10)
        ctx.lineTo(155,10)
        ctx.lineTo(135,55)
        ctx.closePath()
        ctx.translate(100,0)
        ctx.clip()
        ctx.drawImage("images/ball.png",100,10)
        ctx.stroke()
        ctx.restore()
    }
    Component.onCompleted: {
        loadImage("images/ball.png")
    }
}
